package com.deyuanyun.pic.settings.task;

import com.deyuanyun.pic.settings.service.base.BizMsgEventService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;

/**
 *  检测内检测数据录入客户端调用接口失败的任务调度
 *  @author axiao(xj08.dream@gmail.com)
 *  @date 2016-08-10
 *  @version 1.0
 *  Histroy: [修改人][时间][描述]
 */
public class ChkInspResultFailTask extends MethodInvokingJobDetailFactoryBean.StatefulMethodInvokingJob {

    private static final Logger LOGGER = LoggerFactory.getLogger(ChkInspResultFailTask.class);

    @Autowired
    private BizMsgEventService bizMsgEventService;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        try {
            if(LOGGER.isInfoEnabled()) {
                LOGGER.info("***检测内检测数据录入客户端调用接口失败的任务开始执行***");
                JobKey jobKey = context.getTrigger().getJobKey();
                LOGGER.info("得到需要执行的任务名为：" + jobKey.getName());
                LOGGER.info("得到需要执行的任务组名为："  + jobKey.getGroup());
            }
            bizMsgEventService.chkInspResultInputFail();
            if(LOGGER.isInfoEnabled())
                LOGGER.info("***检测内检测数据录入客户端调用接口失败的任务执行结束***");
        } catch (Exception e) {
            LOGGER.error("检测内检测数据录入客户端调用接口失败的任务执行异常", e);
        }
    }
}
